<!DOCTYPE html>
<html
  layout:decorator="components/layout"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  lang="zh-CN"
>
<head>
  <title>系统备份还原</title>
</head>
<body>
<div
  layout:fragment="content"
  class="container"
  id="app" v-cloak
>
  <div class="container">
    <div class="myHeader">
      <div class="myHeader-title">
        数据备份设置
      </div>
    </div>

    <el-form ref="form" label-width="140px">
      <el-form-item label="数据库:">
        <span class="form-value">系统数据库中所有用户表</span>
      </el-form-item>
      <el-form-item label="核验图片:">
        <rx-radio
          v-model="dataBackupSetting.backupIcpPicture"
          :map="fieldFormatter.sysBackupLog.backupIcpPictureMap"
        ></rx-radio>
        <span class="form-help">将备份所有核验图片</span>
      </el-form-item>
      <el-form-item label="通讯文件:">
        <rx-radio
          v-model="dataBackupSetting.backupIcpIspFile"
          :map="fieldFormatter.sysBackupLog.backupIcpIspFileMap"
        ></rx-radio>
        <span class="form-help">系统中所有与省管局进行通讯的文件</span>
      </el-form-item>
      <el-form-item label="自动备份天数:">
        <el-input-number v-model="dataBackupSetting.backupIcpDay" :min="1" :max="10"></el-input-number>
        <span class="form-help">天</span><span class="form-help">系统将在指定天数内自动备份，如果为0将关闭自动备份</span>
      </el-form-item>
      <el-form-item label="保留备份数量:">
        <el-input-number v-model="dataBackupSetting.backupIcpNum" :min="1" :max="10"></el-input-number>
        <span class="form-help">天</span><span class="form-help">请填写保留备份数量，设置过大请注意磁盘是否足够大</span>
      </el-form-item>
    </el-form>
    <div class="myHeader">
      <div class="myHeader-title">
        异地备份设置
      </div>
    </div>
    <el-form ref="form" label-width="140px">
      <el-form-item label="主机名:">
        <el-input v-model="offSiteBackupSetting.backupFtpHost" style="width:400px"></el-input>
        <span class="form-help">请填写SFTP主机名</span>
      </el-form-item>
      <el-form-item label="端口:">
        <el-input v-model="offSiteBackupSetting.backupFtpPort" style="width:400px"></el-input>
        <span class="form-help">请填写SFTP端口，默认端口为</span>
      </el-form-item>
      <el-form-item label="用户名:">
        <el-input maxlength="40" show-word-limit v-model="offSiteBackupSetting.backupFtpUser" style="width:400px"></el-input>
        <span class="form-help">请填写SFTP用户名</span>
      </el-form-item>
      <el-form-item label="密码:">
        <el-input maxlength="40" show-word-limit v-model="offSiteBackupSetting.backupFtpPwd" style="width:400px"></el-input>
        <span class="form-help">请填写SFTP密码</span>
      </el-form-item>
      <el-form-item label="连接模式:">
        <rx-radio
          v-model="offSiteBackupSetting.backupFtpMode"
          :map="fieldFormatter.sysBackupLog.backupFtpModeMap"
        ></rx-radio>
      </el-form-item>
      <el-form-item label="主目录:">
        <el-input v-model="offSiteBackupSetting.backupFtpPath" style="width:400px"></el-input>
        <span class="form-help">请填写SFTP主目录</span>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="updateSettings">设 置</el-button>
        <el-button type="primary" @click="manualBackup">备 份</el-button>
        <el-button type="primary" @click="initSettings">初始化</el-button>
      </el-form-item>
    </el-form>
  </div>

  <div class="container">
    <div class="myHeader">
      <div class="myHeader-title">
        历史备份记录管理
      </div>
    </div>

    <my-table
      :data="page.records"
      :columns="columns"
      @handle-selection-change="selection"
    >
      <template #operating="scope">
        <span>
          <a
            href="#"
            @click="restore(scope.row.id)"
          ><img
            border="0"
            align="absmiddle"
            src="/static/img/db_import.gif"
            width="16"
            alt="恢复"
            v-realm="'system-configuration:data-backup-setting:edit'"
          ></a>
          <a
            href="#"
            @click="deleteBackup(scope.row.id)"
            v-realm="'system-configuration:data-backup-setting:edit'"
          ><img
            border="0"
            src="/static/img/icon_delete.gif"
            align="absmiddle"
            alt="删除"
          ></a>
        </span>
      </template>
    </my-table>
    <div class="pagination">
      <el-pagination
        background
        @size-change="changeSize"
        @current-change="goto"
        :current-page="page.current"
        :page-sizes="[10, 20, 30]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
      >
      </el-pagination>
    </div>
  </div>
</div>
<div layout:fragment="js">
  <script src="/static/js/module/system-config/model/SysBackupLog.js"></script>
  <script src="/static/js/module/system-config/model/DataBackupSetting.js"></script>
  <script src="/static/js/module/system-config/model/OffSiteBackupSetting.js"></script>
  <script src="/static/js/module/system-config/api/sysBackupLogApi.js"></script>
  <script src="/static/js/module/system-config/admin_meta_base.js"></script>
</div>
</body>
</html>
